var rp =require('request-promise');
const {target}=require('../utils/options');

const login=async(params)=>{
    console.log(params)
    var options={
        method:'POST',
        uri:`${target}/admins/login`,
        qs:{},
        body:params,
        json:true
    };
    let data=await rp(options);
    return data;
}

const get=async()=>{
    var options={
        method:'GET',
        uri:`${target}/admins/`,
        qs:{},
        json:true
    };
    let data=await rp(options);
    return data;
}

const create=async(params)=>{
    var options={
        method:'POST',
        uri:`${target}/admins/create`,
        qs:{},
        body:params,
        json:true
    };
    let data=await rp(options);
    return data;
}

const deleted=async(_id)=>{
    console.log(_id)
    var options={
        method:'POST',
        uri:`${target}/admins/dele`,
        qs:{},
        body:{
            _id
        },
        json:true
    };
    let data=await rp(options);
    return data;
}

const update=async(parameter)=>{
    console.log(parameter,"service")
    var options={
        method:'PATCH',
        uri:`${target}/admins/`,
        qs:{},
        body:parameter,
        json:true
    };
    let data=await rp(options);
    return data;
}

const search=async(params)=>{
    var options={
        method:'POST',
        uri:`${target}/admins/search`,
        qs:{},
        body:params,
        json:true
    };
    let data=await rp(options);
    return data;
}

module.exports = {login,get,create,update,deleted,search}